package main

import "fmt"

func printArray(myArray [4]int) {
	// 值拷贝

	for index, value := range myArray {
		fmt.Println("index = ", index, " value = ", value)
	}

	myArray[0] = 111

}

func main() {

	// 固定长度的数组
	var myArray [4]int

	myArray2 := [10]int{1, 2, 3, 4}
	myArray3 := [4]int{11, 22, 33, 44}

	// for i := 0 i < 10; i++ {}
	for i := 0; i < len(myArray); i++ {
		fmt.Println(myArray[i])
	}

	for index, value := range myArray2 {
		fmt.Println("index = ", index, " value = ", value)
	}

	// 查看数组的数据类型
	fmt.Printf("myArray1 types = %T\n", myArray)
	fmt.Printf("myArray2 types = %T\n", myArray2)
	fmt.Printf("myArray3 types = %T\n", myArray3)

	printArray(myArray3)
	fmt.Println(" ----- ")
	for i, v := range myArray3 {
		fmt.Println("i = ", i, " v = ", v)
	}

}
